package com.larry.mr.etl;

import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @ProjectName map-reduce
 * @Author larry
 * @Date 23:07 2022/5/30
 * @Description TODO
 **/
public class VideoETLMapper extends Mapper<LongWritable, Text,Text, NullWritable> {

    Text k = new Text();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String line = value.toString();

        String str = ETLUtils.etlString(line);

        if (StringUtils.isBlank(str)){
            return;
        }

        k.set(str);

        context.write(k,NullWritable.get());
    }
}
